/**
 * Copyright (C), 2019-2022, 宇信融汇
 * FileName: DebugInvocationHandler
 * Author:   86182
 * Date:     2022/4/7 14:35
 * Description:
 * History:
 * <author>          <time>          <version>          <desc>
 * 86182           修改时间           版本号              描述
 */
package test.jdkproxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @Classname DebugInvocationHandler
 * @Description TODO
 * @Date 2022/4/7 14:35
 * @Created by 86182
 */
public class DebugInvocationHandler implements InvocationHandler {

    /**
     * 代理类中的真实对象
     */
    private final Object target;

    public DebugInvocationHandler(Object target) {
        this.target = target;
    }

    /*
    proxy :动态生成的代理类
    method : 与代理类对象调用的方法相对应
    args : 当前 method 方法的参数
     */
    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("brfore");
        Object result = method.invoke(target, args);
        System.out.println("after");
        return result;
    }
}
